<template>
  <div class="mod-config">
    <table-view ref="view"
                :searchAttrs="searchAttrs"
                :primaryKey="primaryKey"
                :listApiName="listApiName"
                :deleteApiName="deleteApiName"
                :saveAuthName="saveAuthName"
                :deleteAuthName="deleteAuthName"
                :showAttrs="showAttrs"
                :sumInfo='sumInfo'
                :exportApiName="exportApiName"
                :optionWidth="300"
    >
      <template v-slot:header>
      </template>
      <template v-slot:foot="{scope}">

      </template>
    </table-view>

  </div>
</template>

<script>
import tableView from '@/components/tableView'
import basicMixins from '@/utils/commonViewMixins'
import radarChart from '@/views/charts/client/clientOrderRadarChart'
import {mRequest} from '@/utils/request'
import {getFormatDateTime,exportHandle,isAuth} from '@/utils'

export default {
  mixins: [basicMixins],
  data() {
    return {
      inventoryDataList: [],
      inventoryLoading: false,
      inventoryDialog: false,
      clientOrderStorageExportDialogVisible: false,
      searchForm: {},
      pageIndex: 1,
      pageSize: 50,
      totalPage: 0,
      selectClientId: '',
      productId: '',
      productInfoList: [],
      dataListSelections: [],
      clientDateTimeRange: '',
      sumInfo:{beforeOughtReceiveAmount:'beforeOughtReceiveAmount',beforeReceiveReduceAmount:'beforeReceiveReduceAmount',nowPayableReduceAmount:'nowPayableReduceAmount',nowPayableAmount:'nowPayableAmount',payableBalanceTotalAmount:'payableBalanceTotalAmount',receivableBalanceTotalAmount:'receivableBalanceTotalAmount'},
      chartSearchObj: {
        dataForm: {
          dateTimeRange: []
        },
        config: {
          dateTimeRange: {
            type: 'date',
            clearable: true,
            dateType: 'daterange',
            label: '时间范围'
          }
        }
      },
      searchAttrs: {
        supplierName: {
          label: '供应商名称',
          clearable: true,
          placeholder: '请输入供应商名称'
        },
        dateTimeRange: {
          type: 'date',
          label: '时间范围',
          dateType: 'datetimerange',
          defaultTime: ['06:00:00', '08:00:00'],
          clearable: true
        },
      },
      primaryKey: 'id',
      listApiName: 'supplierApi/getSupplierAnalysisList',
      exportApiName: 'supplierApi/exportFinanceSupplierAnalysisList',
      deleteApiName: 'supplierApi/deleteSupplierInfo',
      saveAuthName: 'supplier:supplierinfo:save',
      deleteAuthName: 'supplier:supplierinfo:delete',
      templateDownloadApiName: 'supplierApi/downloadSupplierInfo',
      importApiName: 'supplierApi/importSupplierInfo',
      showAttrs: {
        supplierName: {label: '供应商名称'},
        beforeOughtReceiveAmount: {label: '此前应收', width: 120},
        beforeReceiveReduceAmount: {label: '此前应付', width: 120},
        nowPayableAmount: {label: '本期应付', width: 120},
        nowPayableReduceAmount: {label: '本期付款', width: 120},
        payableBalanceTotalAmount: {label: '应付总余额', width: 120,type: 'tag',tagType:'danger'},
        receivableBalanceTotalAmount: {label: '应收总余额', width: 120,type: 'tag',tagType:'success'},
        remark: {label: '备注'},
        status: {
          label: '状态',
          type: 'radio',
          items: [
            {value: 0, text: '禁用', tagType: 'danger'},
            {value: 1, text: '正常'}
          ]
        }
      }
    }
  },
  components: {
    tableView
  },
  methods: {

    exportClientWeightInfo() {
      let startDateTime = ''
      let endDateTime = ''
      if (this.clientDateTimeRange instanceof Array) {
        startDateTime = getFormatDateTime(new Date(this.clientDateTimeRange[0]))
        endDateTime  = getFormatDateTime(new Date(this.clientDateTimeRange[1]))
      }
      exportHandle('orderApi/exportOrderStorageListByClientId', {
        startDateTime: startDateTime,
        endDateTime: endDateTime,
        clientId: this.selectClientId
      })
      this.selectClientId = null
      this.clientOrderStorageExportDialogVisible = false
    },
  }
}
</script>
